{- |
Module      :  Symbols.hs
Description :  List of symbols to be used in a Sudoku Gird
Copyright   :  (c) Michal Parusinski
License     :  GPLv3

Maintainer  :  mparusinski@googlemail.com
Stability   :  experimental
Portability :  portable 

This module is to define Symbol types which are use inside Grids.
It allows for flexible Sudoku grids with different sizes and differents
symbols.
-}

module Symbols where

import qualified Data.Array as Array
import qualified Data.Ix as Ix
import Data.List

class (Show s, Eq s, Ord s) => Symbol s where
    symbols :: [s]

-- 9x9 grids

data DefaultSymbol = One | Two | Three | Four 
                   | Five | Six | Seven 
                   | Eight | Nine
                     deriving (Eq, Ord, Enum, Array.Ix)

instance Symbol DefaultSymbol where
    symbols = enumFrom One

instance Show DefaultSymbol where
    show = printDefaultSymbol

printDefaultSymbol x
    = let lookup = Array.listArray (One,Nine)  [1..9]
      in show $ lookup Array.! x

-- 12x12 grids

data ExtendedSymbol = A | B | C | D 
                    | E | F | G | H
                    | I | J | K | L 
                      deriving (Eq, Ord, Enum, Array.Ix)

instance Symbol ExtendedSymbol where
    symbols = enumFrom A

instance Show ExtendedSymbol where
    show = printExtendedSymbol

printExtendedSymbol x
    = let lookup = Array.listArray (A,L) $ Ix.range ('A','Z')
      in show $ lookup Array.! x

-- Symbol polymorphic code (GOES HERE)

